package common

import (
	"math/rand"
	"time"
)

func RandStringBytes(n int) string {
	letterBytes := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	b := make([]byte, n)
	for i := range b {
		b[i] = letterBytes[rand.Intn(len(letterBytes))]
	}
	return string(b)
}

func RandString(len int) string {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	bytes := make([]byte, len)

	for i := 0; i < len; i++ {
		b := r.Intn(26) + 65
		bytes[i] = byte(b)
	}
	return string(bytes)
}

func RandNum(len int) int64 {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	bytes := make([]byte, len)

	for i := 0; i < len; i++ {
		b := r.Intn(10) + 48
		bytes[i] = byte(b)
	}
	return StringToInt64(string(bytes))
}

func RandomInt(start int, end int) int {
	rand.Seed(time.Now().UnixNano())
	random := rand.Intn(end - start)
	random = start + random
	return random
}
